//
//  ClassTableViewCell.swift
//  UserApp_iOS
//
//  Created by BestVast on 2021/5/18.
//  Copyright © 2021 linlin. All rights reserved.
//

import UIKit
// 分类页面，左侧列表cell
class ClassTableViewCell: UITableViewCell {

    // 左侧 竖着的view
    var leftView  : UIView?

    /// 类型label
    var firstTitle  : UILabel?
    
    /// 右侧三角
    var rightView    : TriangleView?

    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.uiConfig()
    }
    func uiConfig() {
        self.contentView.backgroundColor = UIColor.white
        leftView = UIView.init(frame: CGRect.init(x: 8, y: (self.height - 20) / 2, width: 2, height: 18))
        leftView?.backgroundColor = colorTheme
        self.contentView.addSubview(leftView!)
        
        firstTitle = UILabel.init(frame: CGRect.init(x: 15, y: 10, width: 75, height: 20))
        firstTitle?.font = .systemFont(ofSize: 14)
        firstTitle?.textColor = colorTheme
        self.contentView.addSubview(firstTitle!)
        
        rightView = TriangleView.init(frame: CGRect.init(x: 85, y: (self.height - 18) / 2, width: 7, height: 15))
        rightView?.backgroundColor = .white
        self.contentView.addSubview(rightView!)
    }
    
    /// 设置选中状态和文本
    /// - Parameters:
    ///   - text: 显示文本
    ///   - select: 是否选中
    func selectStatus(text: String, select: Bool)  {
        if select {
            self.contentView.backgroundColor = .white
            leftView?.isHidden = false
            rightView?.isHidden = false
            firstTitle?.textColor = .black
            firstTitle?.text = text
        } else {
            self.contentView.backgroundColor = .white
            leftView?.isHidden = true
            rightView?.isHidden = true
            firstTitle?.textColor = colorTheme
            firstTitle?.text = text
        }
    }
}
